<%-- 
    Document   : add
    Created on : Mar 17, 2012, 1:50:43 AM
    Author     : admin
--%>

<%-- Header Area --%>
<%@ include file="/template/header.jsp" %> 
<%-- End of Header Area --%>


<%-- Content Area --%>

<h2>Add Price</h2>
<div class="submenu">
    <ul>
        <li><a href="/manage">Manage</a></li>
    </ul>
    <div class="clear"></div>
</div>
<form  method="POST" action="">   
    <table class="generic-form-table" cellspacing="0">
        <tr>
            <td>
                <fieldset>
                    <legend>Product Information</legend>
                    <table>
                        <tr>
                            <th>Product</th>
                            <td>
                                <select name="product_id" class="product_id">
                                    <% if (products != null) {%>
                                    <% for (Product p : products) {%>
                                    <option value="<%= p.getId() %>"><%= p.getName()%></option>
                                    <% }%>
                                    <% }%>
                                </select>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </td>
        </tr>
        <tr>
            <td>
                <fieldset>
                    <legend>Pricing</legend>
                    <table>
                        <tr>
                            <th>Size</th>
                            <td>
                                <select name="size" class="size">
                                    <% for (Size s : sizes) { %>
                                    <option value="<%= s.getId() %>"><%= s.getName() %></option>
                                    <% } %>
                                </select>
                            </td>
                            <td>
                                <input type="text" name="price" placeholder="price" validate="form" require="<b>Required</b>" />
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </td>
        </tr>

        <tr>
            <td colspan="2" align="right">
                <input type="submit" value="Submit" name="add" onClick="return validate('form')" />
                <input type="button" value="Reset" onClick="reload()" />
            </td>
        </tr>

    </table>
</form>

<script type="text/javascript">
    $('.product_id').change(function() {
        var id = $('.product_id').val();
        
        //alert(id);
        
        $.post("/manage/price/size", {
            id: id
        }, function(data) {
            if (! data.success) {
                $('.size').attr("disabled", true);
            } else {
                $('.size').attr("disabled", false);
            }
        }, 'json');
    });
</script>

<%-- Footer Area --%>
<%@ include file="/template/footer.jsp" %>
<%-- End of Footer Area --%>